import { RootStateTypes } from '../types';
import { MutationTree, ActionTree } from 'vuex';

const namespaced = true;
interface stateInterface {
  city: string;
}
const state: stateInterface = {
  city: ''
};

const types = {
  CITY: 'CITY'
};

const mutations: MutationTree<stateInterface> = {
  [types.CITY]: (state, city: string) => {
    state.city = city;
  }
};

const actions: ActionTree<stateInterface, RootStateTypes> = {
  setCity({ commit }, city) {
    commit(types.CITY, city);
  }
};

export default { namespaced, state, actions, mutations };
